package cn.iocoder.yudao.module.member.dal.mysql.score;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.member.controller.admin.score.vo.ScoreExportReqVO;
import cn.iocoder.yudao.module.member.controller.admin.score.vo.ScorePageReqVO;
import cn.iocoder.yudao.module.member.dal.dataobject.score.ScoreDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 用户积分记录 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface ScoreMapper extends BaseMapperX<ScoreDO> {

    default PageResult<ScoreDO> selectPage(ScorePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ScoreDO>()
                .eqIfPresent(ScoreDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ScoreDO::getScore, reqVO.getScore())
                .eqIfPresent(ScoreDO::getScoreLevel, reqVO.getScoreLevel())
                .eqIfPresent(ScoreDO::getScoreInfo, reqVO.getScoreInfo())
                .eqIfPresent(ScoreDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(ScoreDO::getScoreActiveTime, reqVO.getScoreActiveTime())
                .betweenIfPresent(ScoreDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScoreDO::getId));
    }

    default List<ScoreDO> selectList(ScoreExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ScoreDO>()
                .eqIfPresent(ScoreDO::getUserId, reqVO.getUserId())
                .eqIfPresent(ScoreDO::getScore, reqVO.getScore())
                .eqIfPresent(ScoreDO::getScoreLevel, reqVO.getScoreLevel())
                .eqIfPresent(ScoreDO::getScoreInfo, reqVO.getScoreInfo())
                .eqIfPresent(ScoreDO::getNumber, reqVO.getNumber())
                .betweenIfPresent(ScoreDO::getScoreActiveTime, reqVO.getScoreActiveTime())
                .betweenIfPresent(ScoreDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ScoreDO::getId));
    }

}
